package com.wgl.yygh.controller.api;

import com.wgl.model.hosp.Hospital;
import com.wgl.model.hosp.Schedule;
import com.wgl.model.vo.hosp.HospitalQueryVo;
import com.wgl.model.vo.hosp.ScheduleOrderVo;
import com.wgl.model.vo.order.SignInfoVo;
import com.wgl.yygh.result.Result;
import com.wgl.yygh.serivce.DepartmentService;
import com.wgl.yygh.serivce.HospitalService;
import com.wgl.yygh.serivce.HospitalSetService;
import com.wgl.yygh.serivce.ScheduleService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.models.auth.In;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author wgl
 * @version 1.0.0
 * @ClassName HospApiController.java
 * @Description TODO
 * @createTime 2022年02月08日 22:33:00
 */
@RestController
@RequestMapping("/api/hosp/hospital")
public class HospApiController {

    @Resource
    private HospitalService hospitalService;
    @Resource
    private DepartmentService departmentService;
    @Resource
    private ScheduleService scheduleService;
    @Resource
    private HospitalSetService hospitalSetService;

    /**
    * @Author: Wgl
    * @Description: 查询医院列表
    * @Date: 2022/2/8 22:39;
    * @param page:
     * @param limit:
     * @param hospitalQueryVo: ;
    * @return: com.wgl.yygh.result.Result;
    */
    @GetMapping("/findHospList/{page}/{limit}")
    public Result findHospList(@PathVariable Integer page, @PathVariable Integer limit, HospitalQueryVo hospitalQueryVo){
        Page page1 = hospitalService.selectHospPage(page, limit, hospitalQueryVo);

        return Result.ok(page1);
    }
    /**
    * @Author: Wgl
    * @Description: 根据医院名称查询
    * @Date: 2022/2/8 22:43;
    * @param hosname: ;
    * @return: com.wgl.yygh.result.Result;
    */
    @GetMapping("/findByHosname/{hosname}")
    public Result findByHosName(@PathVariable String hosname){
        List<Hospital> list = hospitalService.findByHosName(hosname);

        return Result.ok(list);
    }

    /**
    * @Author: Wgl
    * @Description: 根据医院编号查询医院科室信息
    * @Date: 2022/2/8 23:21;
    * @param hoscode: ;
    * @return: com.wgl.yygh.result.Result;
    */
    @GetMapping("/department/{hoscode}")
    public Result findHospDetail(@PathVariable String hoscode){
        return Result.ok(departmentService.findeDeptTree(hoscode));
    }
    /**
    * @Author: Wgl
    * @Description:根据医院编号查询医院详情
    * @Date: 2022/2/8 23:22;
    * @param hoscode: ;
    * @return: com.wgl.yygh.result.Result;
    */
    @GetMapping("/findHospDetail/{hoscode}")
    public Result item(@PathVariable String hoscode){
       Map<String,Object> map =  hospitalService.item(hoscode);
       return Result.ok(map);
    }


    /**
    * @Author: Wgl
    * @Description:获取可预约的排版数据  从mongoDB中获取
    * @Date: 2022/2/13 14:49;
    * @param page:
     * @param limit:
     * @param hoscode:
     * @param depcode: ;
    * @return: com.wgl.yygh.result.Result;
    */
    @GetMapping("/auth/getBookingScheduleRule/{page}/{limit}/{hoscode}/{depcode}")
    public Result getBookingSchedule(@PathVariable Integer page,@PathVariable Integer limit,
                                     @PathVariable String hoscode,@PathVariable String depcode){
        return Result.ok(scheduleService.getBookingScheduleRule(page,limit,hoscode,depcode));
    }
    /**
    * @Author: Wgl
    * @Description:获取排班数据  从mongoDB中获取
    * @Date: 2022/2/13 14:51;
    * @param hoscode:
     * @param depcode:
     * @param workDate: ;
    * @return: com.wgl.yygh.result.Result;
    */
    @GetMapping("/auth/findScheduleList/{hoscode}/{depcode}/{workDate}")
    public Result findScheduleList(@PathVariable String hoscode,@PathVariable String depcode,@PathVariable String workDate){
        return Result.ok(scheduleService.getScheduleDetail(hoscode,depcode,workDate));
    }
    /**
    * @Author: Wgl
    * @Description: 更具id获取排班的详情
    * @Date: 2022/2/13 16:56;
    * @param scheduleId: ;
    * @return: com.wgl.yygh.result.Result;
    */
    @GetMapping("/getSchedule/{scheduleId}")
    public Result getSchedule(@PathVariable String scheduleId){
        Schedule schedule = scheduleService.getScheduleId(scheduleId);
        return Result.ok(schedule);
    }

    /**
    * @Author: Wgl
    * @Description: 根据排班id获得下数据
    * @Date: 2022/2/13 23:02;
    * @param scheduleId: ;
    * @return: com.wgl.model.vo.hosp.ScheduleOrderVo;
    */
    @GetMapping("/inner/getScheduleOrderVo/{scheduleId}")
    public ScheduleOrderVo getScheduleOrderVo(@PathVariable String scheduleId){
        return scheduleService.getScheduleOrderVo(scheduleId);
    }
    /**
    * @Author: Wgl
    * @Description:获取医院签名信息
    * @Date: 2022/2/13 23:25;
    * @param hoscode: ;
    * @return: com.wgl.model.vo.order.SignInfoVo;
    */
    @GetMapping("/inner/getSignInfoVo/{hoscode}")
    public SignInfoVo getSignInfoVo(@PathVariable("hoscode") String hoscode) {
        return hospitalSetService.getSignInfoVo(hoscode);
    }
}
